<!--<?php
if(!$step){print <<<EOT
-->
<section class="section">
			<div class="step">
				<ul id="stepTips">
					<li class="current"><em>1</em>升级提醒</li>
					<li><em>2</em>升级数据</li>
					<li><em>3</em>升级完成</li>
				</ul>
			</div>
			<div style="margin-bottom:30px;" class="success_tip error_tip" id="updateDatabase">
				<p class="f14 b s4">phpwind v{$from_version}  升级至 $wind_version</p>
				<p>升级前请确认站点是否关闭。</p>
				<p>升级前请务必备份好论坛文件和数据库。</p>
				<p>数据库大小：<span class="s1">{$databaseSize}{$unit}</span>
<!--
EOT;
if (!$showBackup){print <<<EOT
-->
				，建议做线下备份
<!--
EOT;
}print <<<EOT
-->
				</p>
			</div>
			<div class="install" id="updateMessage" style="display:none"><ul id="updateMessageList"></ul></div>
			<div style="margin-bottom:30px;" class="bottom tac">
<script src="js/pw_ajax.js"></script>
<script>
var getObj = function(id){
	if(!id){
		return false;
	}
	return document.getElementById(id);
};
var updateUrl = "{$_SERVER['SCRIPT_NAME']}?step=1";

window.onload=function(){
	var updateUrlCookie = FetchCookie('last_update_url');
	if (updateUrlCookie && updateUrlCookie != '0'){
		getObj("continueUpdateObj").style.display='';
		getObj("continueUpdateObj").onclick = function(){
			doUpdate(updateUrlCookie,getObj('startUpdateObj'));
		}
	}
}
function doUpdate(url,obj){
	getObj("continueUpdateObj").style.display='none';
	var stepTips = getObj('stepTips').children;
	stepTips[0].className = 'on';
	stepTips[1].className = 'current';
	obj.className = 'btn_old';
	obj.onclick = function (){return false;}
	obj.innerHTML = '<img src="lang/images/loading.gif" align="absmiddle" />&nbsp;正在升级';
	getObj('updateMessage').style.display='';
	getObj('updateDatabase').style.display='none';
	if (getObj('databaseBackup')){
		getObj('databaseBackup').style.display='none';
	}
	ajaxUpdate(url,obj);
}

function ajaxUpdate(url,obj){
	ajax.send(url,'',function(){
		var rText = ajax.request.responseText.split("\t");
		if (rText[2]) {
			var messages = rText[2].split('|');
			if (messages.length > 1) {
				for(var i=1;i<messages.length;i++){
					var li=document.createElement("li");
					li.innerHTML='<span class="correct_span">√</span>' + messages[0] + messages[i];
					getObj('updateMessageList').appendChild(li);
				} 
			} else {
				var li=document.createElement("li");
				li.innerHTML='<span class="correct_span">√</span>' + rText[2];
				getObj('updateMessageList').appendChild(li);
			}
			getObj('updateMessage').scrollTop = 9999999;
		}
		if (rText[0] == 'continue'){
			SetCookie('last_update_url',rText[1]);
			setTimeout(function(){
				ajaxUpdate(rText[1],obj);
			},1000)
			
		} else if(rText[0] == 'success') {
			SetCookie('last_update_url','0');
			document.location = rText[1];
		} else {
			if (ajax.request.responseText){
				var li=document.createElement("li");
				li.innerHTML='<span class="error_span">√</span>' + ajax.request.responseText;
				getObj('updateMessageList').appendChild(li);
				getObj('updateMessage').scrollTop = 9999999;
			}
			obj.innerHTML = '升级失败';
		}
	});
}
</script>
<!--
EOT;
if ($showBackup){print <<<EOT
-->
<script>

var backupUrl = "{$_SERVER['SCRIPT_NAME']}?step=database";
function databaseBackup(url,obj){
	obj.className = 'btn_old';
	obj.onclick = function(){return false;}
	obj.innerHTML = '备份中...';
	ajax.send(url,'',function(){
		var rText = ajax.request.responseText.split("\t");
		if (rText[0] == 'continue'){
			databaseBackup(rText[1],obj);
		} else if(rText[0] == 'success'){
			obj.innerHTML = '备份完成';
		} else {
			obj.innerHTML = '备份失败';
			setTimeout(function(){
				obj.className = 'btn';
				obj.innerHTML = '重新备份';
				obj.onclick = function(){databaseBackup(backupUrl,obj);}
			},1500);
		}
	});
}
</script>
		<a class="btn" href="javascript:void(0)" onclick="databaseBackup(backupUrl,this);return false;" id="databaseBackup">数据备份</a>
<!--
EOT;
}print <<<EOT
-->
				<a class="btn" href="javascript:void(0)" onclick="doUpdate(updateUrl,this,1);return false;" id="startUpdateObj">开始升级</a>

				<a href="javascript:void(0)" id="continueUpdateObj" style="display:none">上次升级未完成，继续安装?</a>
			</div>
		</section>
<!--
EOT;
}else{
if($step == 'finish'){print <<<EOT
-->
<section class="section">
	<div class="step">
		<ul>
			<li><em>1</em>升级提醒</li>
			<li><em>2</em>升级数据</li>
			<li class="current"><em>3</em>升级完成</li>
		</ul>
	</div>
	<div class="main cc">
		<div class="success_tip">
			<a class="f16 b" href="$bbsurl/index.php">恭喜您，升级完成，点击进入</a>
			<p>浏览器会自动跳转，无需人工干预<img src="http://nt.phpwind.net/src/upto_stats.php?url=$bbsurl&version=$wind_version&type=bbs&charsets=$lang[db_charset]&c=$ceversion" width="0" height="0"></p>
		</div>
	</div>
</section>
<script type="text/javascript">
setTimeout(function(){window.location.href="$bbsurl/index.php"}, 2000);
</script>
<!--
EOT;
}print <<<EOT
-->
</div>
<!--
EOT;
}?>-->